#include "hash.h"

File_t* File[20];

static File_t* NewFile(int filename)
{
	File_t *Head = NULL;

	Head = (File_t*)malloc(sizeof(File_t));
	if (Head)
	{
		memset(Head, 0 , sizeof(File_t));
		Head->iData = filename;
	}

	return Head;
}

static int HashFile(int filename)
{
	int iHash = 0;

	iHash = filename % HASH_FILE;
	return(iHash);
}

static File_t* FindFile(int filename)
{
	int iHashValue = 0;
	File_t *file = NULL;

	iHashValue = HashFile(filename);

	for (file = File[iHashValue]; file != NULL; file = file->Next)
	{
		if (file->iData == filename)
		{
			return file;
		}
	}

	file = NewFile(filename);
	
	file->Next = File[iHashValue];
	File[iHashValue] = file;

	return file;
}

static void DeleteHash(void)
{
	int iSize = sizeof(File) / sizeof(File[0]);
	int iCnt = 0;

	for (iCnt = 0; iCnt < iSize; iCnt++)
	{
		
	}
}

int main(void)
{
	FindFile(343);
	FindFile(12);
	FindFile(34);
	FindFile(3);
	FindFile(65);
	DeleteHash();

	return(0);
}